Using GNUPLOT for LATEX: a Tutorial

GNUPLOT is by nature an interactive program. Users making plots for LATEX will generally not use GNUPLOT interactively. Whenever hard copy is desired from GNUPLOT, the program need not be run on a graphics terminal. In this case the output is directed to a file or pipe, then sent to the appropriate output device. For example, output from the terminal type unixplot may be sent to a program interpreting the Unix plotting standard. The terminal types imagen and postscript may be used for output to printers understanding those languages. (A shell script (lasergnu) is supplied with the distribution that will accept a GNUPLOT command or input file and send the output to an Imagen or Postscript laser printer. This script may have been adapted to your site.) The terminal type fig outputs FIG code that can be read by the Fig graphics program and translated into forms usable in both TEX and LATEX documents.

We now ignore the interactive nature of GNUPLOT and provide the input to GNUPLOT from a file, ,

      gnuplot gnu.input
In this example, all of the commands to GNUPLOT are contained in the file gnu.input. Multiple filenames may be supplied to GNUPLOT this way, read in the order they are given. The output (one or more plots) may be piped to another program or redirected to a file. Usually, however, we direct the output explicitly with an instruction to GNUPLOT (the set output command). GNUPLOT continues to print error messages to the terminal (stderr).



Subsections